home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume5 / mpss / part04 < prev    next >
Encoding:
Internet Message Format  |  1988-07-20  |  35.5 KB

  1. Path: uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games
  2. From: games@tekred.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v05i010:  mpss - multi-player Star Trek game, Part04/04
  5. Message-ID: <2822@tekred.TEK.COM>
  6. Date: 21 Jul 88 00:03:35 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 1359
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted by: Peer Schmitz <peer@cs.kl.ac.uk>
  12. Comp.sources.games: Volume 5, Issue 10
  13. Archive-name: mpss/Part04
  14.  
  15.  
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 4 (of 4)."
  24. # Contents:  InstallRules.ms aliens.c auto.c collision.c dock.c files.h
  25. #   header.h keyscan.c makefile.dist mpssclean.c mpssmail planets.h
  26. #   setupuniverse.c ships.h
  27. # Wrapped by billr@saab on Wed Jul 20 17:00:28 1988
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'InstallRules.ms' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'InstallRules.ms'\"
  31. else
  32. echo shar: Extracting \"'InstallRules.ms'\" \(3781 characters\)
  33. sed "s/^X//" >'InstallRules.ms' <<'END_OF_FILE'
  34. X.TH
  35. XHow to install or alter MPSS.
  36. X.SH
  37. XSETIING UP THE FILES
  38. X.LP
  39. XIf mpss lives in one directory, a subdirectory called "mpsslib" must
  40. Xbe created. "mpsslib" must have permissions 0777 (rwx for all!). Before
  41. Xcompiling the program make sure that all file names in the file "files.h"
  42. Xhave been altered accordingly. Make sure that this file contains the
  43. XFULL pathnames of any files accessed.
  44. Xinside mpsslib we put 3 files, with permissions as follows and owner
  45. Xof all three being daemon. (ALL THIS MUST BE FOR THE GAME TO WORK!!)
  46. XAll files in mpsslib must have permission 4755 or 4777 as shown below.
  47. X(i.e. they set uid as soon as they are invoked.)
  48. X
  49. X"mpsslib" should look like this :
  50. X.DS L
  51. X
  52. Xtotal 144
  53. X-rwsrwxrwx  1 daemon         59 May 11 15:06 mpssmail (file exec. on a new game)
  54. X-rwsr-xr-x  1 daemon      44032 May 12 11:07 slave (invoked by ../mpss)
  55. X-rwsr-xr-x  1 daemon      98304 May 12 11:11 startrek (the master game&process!)
  56. X
  57. Xthe directory above mpsslib should look like this :
  58. X
  59. X-rwsr-xr-x 1 daemon      mpssclean (to clean up a mess if there is one)
  60. X-rwxr-xr-x 1 anyone      mpss (proggie to invoke the full game)
  61. X-rwxr-xr-x 1 anyone      mpssrules (nroff -ms format)
  62. Xdrwxrwxrwx 1 anyone      mpsslib (subdirectory for all files.)
  63. X
  64. X.DE
  65. X.SH
  66. XHow to change mpss.
  67. X.LP
  68. XTo add another type of terminal.
  69. X.LP
  70. XAll the terminal control strings are defined in cursor.c . So, if you wish
  71. Xto add another terminal, put in another case for it in all 3 relevant
  72. Xprocedures in that file. Then edit slave.c and allow the variable tty_type
  73. Xto get that value. (look in procedure gettermdata() ).
  74. XMake sure not to mess about with case 0, which is to exit the proggie in case
  75. Xof doubt. After that invoke mpss not using the -t option and choose the terminal
  76. Xyou have implemented.
  77. X.SH
  78. XStructure of the game..
  79. X.LP
  80. XFirst note that the entire game is controlled by one main master process.
  81. XHeres a sample run of what goes on. (The file main.c contains the main game iteration loop.)
  82. X.LP
  83. XA guy invokes mpss. This tiny proggie only sets the players umask to 000 and
  84. Xopens the /dev/ttyxx file of the player and makes it rw access for all, so
  85. Xthe master proggie can write/read from that terminal. Mpss then execls 
  86. X/mpsslib/slave which is owned by daemon so it can send signals to the
  87. Xmaster-star-trek proggie that is also owned by daemon.  Now, slave starts running. If the mpsslib/masterpid (MASTERPIDFILE) isnt there, this means that the
  88. Xmaster process isnt running yet. Slave makes a LOCK file and if the master
  89. Xisnt there, invokes it. If it is there (i.e. masterpid is present) it 
  90. Xcarries on. After waiting until the masterpidfile appears, slave makes
  91. Xa PLAYERFILE, mpss/player, reads the master process id out of masterpid,
  92. Xand signals the masterprocess that a playerfile is there. The master process
  93. Xgets the signal, reads the playerfile enters the player into the list of players and starts to play him. The master removes the playerfile then, and 
  94. Xthen slave removes the LOCK file. No other slave will make a player file
  95. Xif the lock file is present. The playerfile contains the shipnumber,cursor motion and clear screen strings, as well as the players terminal name. After
  96. Xa player starts playing, if he dies, a playerscorefile is made, and the
  97. Xwaiting slave process is signalled. It reads the playerscorefile, then the
  98. Xscore file (which contains the scoreboard) adds him in, writes back the
  99. Xscoreboard and removes the playerscorefile.r
  100. XOther files in the game are "shipnumber" wich only contains a number between
  101. X0-28 keeping track of which ship is to be allocated next. omakefile makes
  102. Xeverything with the -O option, gmakefile makes everything with the -g option.
  103. X
  104. XLIVE LONG & PROSPER
  105. XAny problems? ask Peer Schmitz, Department of Computer Science
  106. XUniversity of Keele, Keele, Staffs, ST5-5BG
  107. X
  108. X
  109. X
  110. END_OF_FILE
  111. if test 3781 -ne `wc -c <'InstallRules.ms'`; then
  112.     echo shar: \"'InstallRules.ms'\" unpacked with wrong size!
  113. fi
  114. # end of 'InstallRules.ms'
  115. fi
  116. if test -f 'aliens.c' -a "${1}" != "-c" ; then 
  117.   echo shar: Will not clobber existing file \"'aliens.c'\"
  118. else
  119. echo shar: Extracting \"'aliens.c'\" \(3833 characters\)
  120. sed "s/^X//" >'aliens.c' <<'END_OF_FILE'
  121. X#include "ships.h"
  122. X#include "header.h"
  123. X
  124. Xmakealien(cp)
  125. Xregister struct player *cp;
  126. X{
  127. Xchar *malloc(); 
  128. Xstruct player *aa;
  129. X
  130. Xaa=(struct player *)malloc(sizeof(struct player));
  131. X
  132. Xi=(int)rnd(0,10);
  133. Xif (i>5) {
  134. X        aa->id=ROMID;
  135. X        aa->xpos=600;
  136. X        aa->ypos=100;
  137. X       } else
  138. X       {
  139. X        aa->id=KLINGID;
  140. X        aa->xpos=600;
  141. X        aa->ypos=575;
  142. X       }
  143. X
  144. Xaa->impulsemove=0;
  145. Xaa->cm[0]='\0';
  146. Xaa->cl[0]='\0';
  147. Xaa->cm[0]='\0';
  148. Xaa->terminalfile[0]='\0';
  149. Xaa->shipno=28;
  150. Xaa->tty_type= -1;
  151. Xaa->pid=99999;
  152. Xaa->doneit=0;
  153. Xaa->reason=10;
  154. Xaa->oldxpos=aa->xpos;
  155. Xaa->oldypos=aa->ypos;
  156. Xaa->beeping=ON;
  157. Xaa->maxvel=MAXWARP;
  158. Xaa->xvel=0;
  159. Xaa->yvel=0;
  160. Xaa->chflg=FLAG;
  161. Xaa->clflg=OFF;
  162. Xaa->stat=3;
  163. Xaa->energy=STARTENERGY;
  164. Xaa->maxenergy=STARTENERGY;
  165. Xaa->phaserbanks=STARTPHASER;
  166. Xaa->maxphaser=STARTPHASER;
  167. Xaa->photontorpedos=STARTPHOTON;
  168. Xaa->maxphoton=STARTPHOTON;
  169. Xaa->photonpower=PHOTONPOWER;
  170. Xaa->phaserpower=PHASERPOWER;
  171. Xif (aa->id==ROMID) 
  172. X    {
  173. X    aa->photonpower= aa->photonpower+20;
  174. X    aa->phaserpower= aa->phaserpower+20;
  175. X    }
  176. Xaa->photonreach=WEAPONREACH+4;
  177. Xaa->phaserreach=WEAPONREACH+4;
  178. Xaa->weaponselect=0;
  179. Xaa->score=0;
  180. Xaa->cloakingdevice=OFF;
  181. Xaa->shields=OFF;
  182. Xfor(k=0;k<30;++k)
  183. X    aa->planets[k]=0;
  184. Xaa->planetno=0;
  185. Xfor (k=0; k<=3; k++)
  186. X    {
  187. X    aa->channel[k].enemy=NULL;
  188. X    aa->channel[k].xloc=0;
  189. X    aa->channel[k].yloc=0;
  190. X    }
  191. Xaa->flyto= -1;
  192. Xaa->messindex=0;
  193. X    addtolist(aa);
  194. X++noofaliens;
  195. X}
  196. X
  197. Xservicealien(cp)
  198. Xregister struct player *cp;
  199. X{
  200. X    
  201. Xif (cp->messindex==1) 
  202. X    { 
  203. X    if (autopilotalien(cp)==0) goto movealien; 
  204. X         else
  205. X        {
  206. X        /*we have arrived. Now attack the guy*/
  207. X        if (cp->weaponselect==0)
  208. X            {
  209. X            i=rand()%100;
  210. X            if (i<6)
  211. X                {
  212. X                fire_torpedo(cp,'6',0);
  213. X                cp->messindex=0;
  214. X                i=rand()%100;
  215. X                if (i<50)
  216. X                    cp->yvel=1;
  217. X                }
  218. X            } else
  219. X            {
  220. X            i=rand()%100;
  221. X            if (i<6)
  222. X                {
  223. X                fire_torpedo(cp,'4',0);
  224. X                cp->messindex=0;
  225. X                i=rand()%100;
  226. X                if (i<50)
  227. X                    {
  228. X                    cp->yvel=1;
  229. X                    cp->xvel=1;
  230. X                    }
  231. X                }
  232. X            }
  233. X        }
  234. X    }
  235. Xi=rand()%10000;
  236. Xif (i==9995) {
  237. X         j=rand()%10;
  238. X         if (cp->messindex==0 && j<2) lockonalien(cp,NULL); else cp->messindex=0;
  239. X         }
  240. Xif (i<9920) {goto movealien;}
  241. Xif ((i>=9920)&&(i<9995)) {cp->xvel=0; cp->yvel=0; goto movealien;}
  242. Xif (i==9996) {cp->xvel = -1; goto movealien;}
  243. Xif (i==9997) {cp->xvel = 1; goto movealien;}
  244. Xif (i==9998) {cp->yvel = 1; goto movealien;}
  245. Xif (i==9999) cp->yvel = -1; 
  246. X
  247. Xmovealien :
  248. X
  249. Xcp->oldxpos=cp->xpos;
  250. Xcp->oldypos=cp->ypos;
  251. Xcp->xpos+=cp->xvel;
  252. Xcp->ypos+=cp->yvel;
  253. Xif (((cp->yvel!=0)||(cp->xvel!=0))&&(cp->stat<12)) cp->chflg=FLAG;
  254. X}
  255. X
  256. Xgethim(who,enemyid)
  257. Xregister struct player *who;
  258. Xchar enemyid;
  259. X{
  260. Xregister struct player *x;
  261. Xif (noofplayers>1) return(0);
  262. Xx=startlist;
  263. Xwhile (x!=NULL && x->id!=enemyid) x=x->next;
  264. Xif (x!=NULL) lockonalien(x,who);
  265. X}
  266. X
  267. Xlockonalien(cp,who)
  268. Xregister struct player *cp,*who;
  269. X{
  270. Xregister struct player *x;
  271. X
  272. Xif (cp->stat==12) return(0);
  273. X
  274. Xi=rand()%1000;
  275. Xif (i>500) cp->weaponselect=0; else cp->weaponselect=1;
  276. Xif (who==NULL)
  277. X    {
  278. X    x=startlist;
  279. X    while (x!=NULL)
  280. X    {
  281. X    if (x==cp) {x=x->next; continue;}
  282. X    if ((x->shields==OFF)&&(x->id!=ROMID)&&(x->id!=KLINGID))
  283. X        {
  284. X        cp->channel[1].enemy=x;
  285. X        cp->channel[1].xloc=0;
  286. X        cp->channel[1].yloc=0;
  287. X        cp->messindex=1;
  288. X        } 
  289. X    x=x->next;
  290. X    }  
  291. X    } else
  292. X    {
  293. X        cp->channel[1].enemy=who;
  294. X        cp->channel[1].xloc=0;
  295. X        cp->channel[1].yloc=0;
  296. X        cp->messindex=1;
  297. X    }
  298. X}
  299. X
  300. Xautopilotalien(cp)
  301. Xregister struct player *cp;
  302. X{
  303. Xif (cp->weaponselect==0)
  304. X    {
  305. X    if (cp->xpos!=(cp->channel[1].enemy->xpos-7))
  306. X        {
  307. X    if (cp->xpos<(cp->channel[1].enemy->xpos-7)) cp->xvel=1; else cp->xvel= -1;
  308. X        } else cp->xvel=0;
  309. X    } else
  310. X    {
  311. X    if (cp->xpos!=(cp->channel[1].enemy->xpos+6))
  312. X        {
  313. X    if (cp->xpos<(cp->channel[1].enemy->xpos+6)) cp->xvel=1; else cp->xvel= -1;
  314. X        } else cp->xvel=0;
  315. X    }
  316. Xif (cp->ypos!=cp->channel[1].enemy->ypos)
  317. X        {
  318. X    if (cp->ypos<cp->channel[1].enemy->ypos) cp->yvel=1; else cp->yvel= -1;
  319. X        } else cp->yvel=0;
  320. X
  321. X/* arrival at location*/
  322. Xif ((cp->xvel==0)&&(cp->yvel==0)) return(1); else return(0);
  323. X}
  324. X
  325. END_OF_FILE
  326. if test 3833 -ne `wc -c <'aliens.c'`; then
  327.     echo shar: \"'aliens.c'\" unpacked with wrong size!
  328. fi
  329. # end of 'aliens.c'
  330. fi
  331. if test -f 'auto.c' -a "${1}" != "-c" ; then 
  332.   echo shar: Will not clobber existing file \"'auto.c'\"
  333. else
  334. echo shar: Extracting \"'auto.c'\" \(3194 characters\)
  335. sed "s/^X//" >'auto.c' <<'END_OF_FILE'
  336. X/*******************************************************************************
  337. X********************************************************************************
  338. X********************************************************************************
  339. X
  340. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  341. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  342. X
  343. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  344. X
  345. X
  346. X********************************************************************************
  347. X********************************************************************************
  348. X*******************************************************************************/
  349. X
  350. X#include "header.h"
  351. X
  352. Xlock_on(cp,chno) 
  353. Xregister struct player *cp;
  354. Xint chno;
  355. X{
  356. Xregister struct player *x;
  357. Xint lockok;
  358. X
  359. Xlockok=OFF;
  360. Xx=startlist;
  361. Xwhile (x!=NULL)
  362. X{
  363. X    if (x==cp) {x=x->next; continue;}
  364. X    if ((cp->xpos==x->xpos)&&(cp->ypos==x->ypos))
  365. X        {
  366. X        cp->channel[chno].enemy=x;
  367. X        cp->channel[chno].xloc=0;
  368. X        cp->channel[chno].yloc=0;
  369. X        lockok=ON;
  370. Xplot1(cp,"        Tractor beam locked onto enemy captain!          ");
  371. Xplot2(cp,"                                                         ");
  372. X        x=NULL;
  373. X        } else
  374. X        x=x->next;
  375. X}
  376. Xif (lockok==OFF)
  377. X    {
  378. X    cp->channel[chno].enemy=NULL;
  379. X    cp->channel[chno].xloc=cp->xpos;
  380. X    cp->channel[chno].yloc=cp->ypos;
  381. X    if (inuniv(cp->xpos,cp->ypos)=='*')
  382. X    {
  383. Xplot1(cp,"         Tractor beam locked onto starbase captain!      ");
  384. Xplot2(cp,"                                                         ");
  385. X    } else
  386. X    {
  387. Xplot1(cp,"    Tractor beam locked onto this quadrant captain!      ");
  388. Xplot2(cp,"                                                         ");
  389. X    }
  390. X    }
  391. X    
  392. X}
  393. X
  394. Xdisplaybeams(cp) 
  395. Xregister struct player *cp;
  396. X{
  397. Xchar str[7];
  398. Xint i;
  399. Xposcurs(cp,23,22);
  400. Xfor (i=0; i<4; i++)
  401. X{
  402. Xsprintf(str,"%1d)",(i+1));
  403. Xwrite(cp->fd,str,2);
  404. Xif (cp->channel[i].enemy==NULL)
  405. X    {
  406. X    if (inuniv(cp->channel[i].xloc,cp->channel[i].yloc)=='*')
  407. X        write(cp->fd,"*:",2);
  408. X    sprintf(str,"%3d,",cp->channel[i].xloc);
  409. X    write(cp->fd,str,4);
  410. X    sprintf(str,"%3d ",cp->channel[i].yloc);
  411. X    write(cp->fd,str,4);
  412. X    } else
  413. X    {
  414. X    sprintf(str,"%1c:",cp->channel[i].enemy->id);
  415. X    write(cp->fd,str,2);
  416. X    sprintf(str,"%3d,",cp->channel[i].enemy->xpos);
  417. X    write(cp->fd,str,4);
  418. X    sprintf(str,"%3d ",cp->channel[i].enemy->ypos);
  419. X    write(cp->fd,str,4);
  420. X    }
  421. X}
  422. X}
  423. X
  424. Xauto_pilot(cp)
  425. Xregister struct player *cp;
  426. X{
  427. Xint x;
  428. Xx=cp->flyto;
  429. Xif (cp->channel[x].enemy==NULL)
  430. X{
  431. Xif (cp->xpos!=cp->channel[x].xloc)
  432. X        {
  433. X        if (cp->xpos<cp->channel[x].xloc) cp->xvel=1; else cp->xvel= -1;        } else cp->xvel=0;
  434. Xif (cp->ypos!=cp->channel[x].yloc)
  435. X        {
  436. X        if (cp->ypos<cp->channel[x].yloc) cp->yvel=1; else cp->yvel= -1;
  437. X        } else cp->yvel=0;
  438. X} else
  439. X{
  440. Xif (cp->xpos!=cp->channel[x].enemy->xpos)
  441. X        {
  442. X    if (cp->xpos<cp->channel[x].enemy->xpos) cp->xvel=1; else cp->xvel= -1;
  443. X        } else cp->xvel=0;
  444. Xif (cp->ypos!=cp->channel[x].enemy->ypos)
  445. X        {
  446. X    if (cp->ypos<cp->channel[x].enemy->ypos) cp->yvel=1; else cp->yvel= -1;
  447. X        } else cp->yvel=0;
  448. X}
  449. X
  450. X/* arrival at location*/
  451. Xif ((cp->xvel==0)&&(cp->yvel==0))
  452. X    {
  453. X    plotstatus(cp,3);
  454. X    cp->flyto= -1;
  455. X    plot1(cp," Sulu : We have arrived at the programmed location Sir.  ");
  456. X    plot2(cp,"                                                         ");
  457. X    }
  458. X}
  459. X
  460. END_OF_FILE
  461. if test 3194 -ne `wc -c <'auto.c'`; then
  462.     echo shar: \"'auto.c'\" unpacked with wrong size!
  463. fi
  464. # end of 'auto.c'
  465. fi
  466. if test -f 'collision.c' -a "${1}" != "-c" ; then 
  467.   echo shar: Will not clobber existing file \"'collision.c'\"
  468. else
  469. echo shar: Extracting \"'collision.c'\" \(3656 characters\)
  470. sed "s/^X//" >'collision.c' <<'END_OF_FILE'
  471. X
  472. X/*******************************************************************************
  473. X********************************************************************************
  474. X********************************************************************************
  475. X
  476. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  477. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  478. X
  479. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  480. X
  481. X
  482. X********************************************************************************
  483. X********************************************************************************
  484. X*******************************************************************************/
  485. X#include "header.h"
  486. X
  487. Xcollision(cp,c)
  488. Xregister struct player *cp;
  489. Xchar c;
  490. X{
  491. X/*check for any collisions*/
  492. Xswitch (c)
  493. X    {
  494. X    
  495. Xcase '@' :
  496. X    {
  497. X    plot1(cp,"You were sucked into a black hole and whirled out again. ");
  498. X    plot2(cp,"This means your weapons have been damaged.   Better dock!");
  499. X    cp->phaserbanks=0;
  500. X    cp->photontorpedos=0;
  501. X    plotphaserbanks(cp);
  502. X    plotphotontorpedos(cp);
  503. X    if (cp->stat!=5) plotstatus(cp,4);
  504. X    break;
  505. X    }
  506. Xcase 'O' :
  507. X    {
  508. X    plot1(cp,"   You  crashed  into  a planet.  Oh  dear,  Oh  dear,   ");
  509. X    plot2(cp,"   The crater you left was 12 miles wide. Your'e Dead!   ");
  510. X    if (cp->reason>0) cp->reason= -1;
  511. X    finish(cp);
  512. X    break;
  513. X    }
  514. Xcase '.' :
  515. X    {
  516. X    cp->maxenergy -= 30;
  517. X    cp->energy -= 30;
  518. X    plotenergy(cp);
  519. X    plotmaxenergy(cp);
  520. X    plot1(cp,"    You collided with a star. Warp capability has been   ");
  521. X    plot2(cp,"    reduced by 30, and your  energy  is  30 lower now.   ");
  522. X    if (cp->stat!=5) plotstatus(cp,4);
  523. X    break;
  524. X    }
  525. Xcase 'k' :
  526. X    {
  527. X    cp->maxenergy -= 100;
  528. X    cp->energy -= 100;
  529. X    plotenergy(cp);
  530. X    plotmaxenergy(cp);
  531. X    plot1(cp,"    You collided with a klingon mevisic mine...          ");
  532. X    plot2(cp,"    Energy and Maxenergy have dropped by 100.            ");
  533. X    if (cp->stat!=5) plotstatus(cp,4);
  534. X    break;
  535. X    }
  536. Xcase '#' :
  537. X    {
  538. X    cp->maxenergy -= 400;
  539. X    cp->energy -= 400;
  540. X    plotenergy(cp);
  541. X    plotmaxenergy(cp);
  542. X    plot1(cp,"    You collided with a Romulan Warning buoy.            ");
  543. X    plot2(cp,"    Energy and Maxenergy have dropped by 400.            ");
  544. X    if (cp->stat!=5) plotstatus(cp,4);
  545. X    break;
  546. X    }
  547. Xcase 'o' :
  548. X    {
  549. X    if (cp->doneit==1) 
  550. X    {
  551. X    plot1(cp,"    You CANNOT try that again you moron!!! That would    ");
  552. X    plot2(cp,"    allow anyone to get any score.....bye bye........    ");
  553. X    if (cp->reason>0) cp->reason= -5;
  554. X    finish(cp);
  555. X    break;
  556. X    } else
  557. X    {
  558. X    cp->maxvel+=1;
  559. X    cp->score+=100;
  560. X    plotscore(cp);
  561. X    cp->maxphaser += 10;
  562. X    cp->maxphoton += 10;
  563. X    cp->photonpower +=20;
  564. X    cp->phaserpower += 20;
  565. X    cp->phaserreach +=5;
  566. X    cp->photonreach +=5;
  567. X    plotphaserbanks(cp);
  568. X    plotphotontorpedos(cp);
  569. X    cp->doneit=1;
  570. X    cp->maxenergy += 110;
  571. X    cp->energy += 110;
  572. X    plotenergy(cp);
  573. X    plotmaxenergy(cp);
  574. X    plot1(cp," You fell through a time warp.  Just look what this has  ");
  575. X    plot2(cp," done to your ship. You obviously went into the future!! ");
  576. X    break;
  577. X    }
  578. X    }
  579. Xdefault : break;
  580. X    }
  581. X}
  582. X
  583. Xfinish(x)
  584. Xregister struct player *x;
  585. X{
  586. Xstruct player *r;
  587. X
  588. Xif (x->stat<12)
  589. X    {
  590. X    x->chflg=FLAG;
  591. X    fire_torpedo(x,'1',1);
  592. X    fire_torpedo(x,'2',1);
  593. X    fire_torpedo(x,'3',1);
  594. X    fire_torpedo(x,'4',1);
  595. X    fire_torpedo(x,'8',1);
  596. X    fire_torpedo(x,'6',1);
  597. X    fire_torpedo(x,'7',1);
  598. X    fire_torpedo(x,'9',1);
  599. X    plotstatus(x,12);
  600. X    x->messindex= -1;
  601. X    }
  602. Xif (x->id!=ROMID && x->id!=KLINGID)
  603. X    {
  604. X    beep(x);
  605. X    beep(x);
  606. X    }
  607. X}
  608. X
  609. Xwhich_sector(x,y,xv,yv)
  610. Xint x,y,xv,yv;
  611. X{
  612. X    x+=xv;
  613. X    x+=xv;
  614. X    y+=yv;
  615. X    y+=yv;
  616. X    if ((x<58)||(x>899)||(y<19)||(y>899)) return(0);
  617. X    if ((x>450)&&(x<899))
  618. X        {
  619. X        if ((y<450)&&(y>19)) return(4);
  620. X        else 
  621. X        if ((y>450)&&(y<899)) return(2);
  622. X        }
  623. X    if ((x<450)&&(x>58))
  624. X        {
  625. X        if ((y>450)&&(y<899)) return(1);
  626. X        else 
  627. X        if ((y<450)&&(y>19)) return(3);
  628. X        }
  629. X}
  630. X
  631. END_OF_FILE
  632. if test 3656 -ne `wc -c <'collision.c'`; then
  633.     echo shar: \"'collision.c'\" unpacked with wrong size!
  634. fi
  635. # end of 'collision.c'
  636. fi
  637. if test -f 'dock.c' -a "${1}" != "-c" ; then 
  638.   echo shar: Will not clobber existing file \"'dock.c'\"
  639. else
  640. echo shar: Extracting \"'dock.c'\" \(2328 characters\)
  641. sed "s/^X//" >'dock.c' <<'END_OF_FILE'
  642. X
  643. X/*******************************************************************************
  644. X********************************************************************************
  645. X********************************************************************************
  646. X
  647. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  648. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  649. X
  650. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  651. X
  652. X
  653. X********************************************************************************
  654. X********************************************************************************
  655. X*******************************************************************************/
  656. X
  657. X#include "header.h"
  658. X
  659. Xdock(cp)
  660. Xregister struct player *cp;
  661. X{
  662. Xint dockingok;
  663. X
  664. Xdockingok=OFF;
  665. Xi=cp->xpos;
  666. Xj=cp->ypos;
  667. Xif ((inuniv(i,j)=='*') && ((cp->xvel==0) && (cp->yvel==0)))
  668. X        dockingok=ON;
  669. Xif (dockingok==OFF)
  670. X    {
  671. X    plot1(cp,"   Your'e not beside a federation starbase Captain.      ");
  672. X    plot2(cp,"                                                         ");
  673. X    } else
  674. X    {
  675. X    if ((cp->cloakingdevice)||(cp->shields))
  676. X        {
  677. X        if (cp->shields)
  678. X        {
  679. X    plot1(cp,"                                                         ");
  680. X    plot2(cp,"   While you have your shields are up? Youre kidding!    ");
  681. X        }
  682. X        else
  683. X        {
  684. X    plot1(cp,"                                                         ");
  685. X    plot2(cp,"          While you are cloaked? -come off it!           ");
  686. X        } 
  687. X    } else
  688. X        {
  689. X        plot1(cp,"               Docking procedure completed.              ");
  690. X        plot2(cp,"         Weapons and Crystal Units recharged Captain.    ");
  691. X        plotstatus(cp,7);
  692. X
  693. X        if (cp->maxenergy>=STARTENERGY)
  694. X            cp->energy=cp->maxenergy;
  695. X            else
  696. X            {
  697. X            cp->energy=STARTENERGY;
  698. X            cp->maxenergy=STARTENERGY;
  699. X            }
  700. X        cp->phaserbanks=cp->maxphaser;
  701. X        cp->photontorpedos=cp->maxphoton;
  702. X        plotenergy(cp);
  703. X        plotmaxenergy(cp);
  704. X        plotphaserbanks(cp);
  705. X        plotphotontorpedos(cp);
  706. X        }
  707. X    }
  708. X}
  709. X
  710. Xundock(cp)
  711. Xregister struct player *cp;
  712. X{
  713. Xif ((cp->stat==7) && (cp->xvel==0) && (cp->yvel==0)) 
  714. X{
  715. Xplot1(cp," Un-docking successful Captain. No casualties this time. ");
  716. Xplot2(cp,"                   Your'e improving...                   ");
  717. Xplotstatus(cp,3);
  718. X} else
  719. X{
  720. Xplot1(cp,"Tell me :- How can you un-dock when your'e not docked??? ");
  721. Xplot2(cp,"                                                         ");
  722. X}
  723. X}
  724. X
  725. X
  726. END_OF_FILE
  727. if test 2328 -ne `wc -c <'dock.c'`; then
  728.     echo shar: \"'dock.c'\" unpacked with wrong size!
  729. fi
  730. # end of 'dock.c'
  731. fi
  732. if test -f 'files.h' -a "${1}" != "-c" ; then 
  733.   echo shar: Will not clobber existing file \"'files.h'\"
  734. else
  735. echo shar: Extracting \"'files.h'\" \(1126 characters\)
  736. sed "s/^X//" >'files.h' <<'END_OF_FILE'
  737. X
  738. X/*******************************************************************************
  739. X********************************************************************************
  740. X********************************************************************************
  741. X
  742. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  743. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  744. X
  745. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  746. X
  747. X
  748. X********************************************************************************
  749. X********************************************************************************
  750. X*******************************************************************************/
  751. X
  752. X
  753. X#define SLAVEPROGRAM "/usr/games/mpsslib/slave"
  754. X#define MASTERPROGRAM "/usr/games/mpsslib/startrek"
  755. X
  756. X#define PLAYERFILE "/usr/games/mpsslib/player"
  757. X#define MASTERPIDFILE "/usr/games/mpsslib/masterpid"
  758. X#define LOCK "/usr/games/mpsslib/lock"
  759. X#define SHIPNOFILE "/usr/games/mpsslib/shipnumber"
  760. X#define SCOREFILE "/usr/games/mpsslib/score"
  761. X#define PLAYERSCOREFILE "/usr/games/mpsslib/playerscore"
  762. X#define MAILFILE "/usr/games/mpsslib/mpssmail"
  763. X
  764. END_OF_FILE
  765. if test 1126 -ne `wc -c <'files.h'`; then
  766.     echo shar: \"'files.h'\" unpacked with wrong size!
  767. fi
  768. # end of 'files.h'
  769. fi
  770. if test -f 'header.h' -a "${1}" != "-c" ; then 
  771.   echo shar: Will not clobber existing file \"'header.h'\"
  772. else
  773. echo shar: Extracting \"'header.h'\" \(3100 characters\)
  774. sed "s/^X//" >'header.h' <<'END_OF_FILE'
  775. X
  776. X/*******************************************************************************
  777. X********************************************************************************
  778. X********************************************************************************
  779. X
  780. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  781. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  782. X
  783. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  784. X
  785. X
  786. X********************************************************************************
  787. X********************************************************************************
  788. X*******************************************************************************/
  789. X
  790. X
  791. X#include <stdio.h>
  792. X#include <sys/ioctl.h>
  793. X#include <sgtty.h>
  794. X#include <signal.h>
  795. X
  796. X#define STARTENERGY 500 
  797. X#define STARTPHASER 15
  798. X#define STARTPHOTON 10
  799. X#define WEAPONREACH 6
  800. X#define PHOTONPOWER 60
  801. X#define PHASERPOWER 40
  802. X#define MAXWARP 1
  803. X#define FLAG 2 
  804. X#define ON 1
  805. X#define OFF 0
  806. X#define ROMID 'R'
  807. X#define KLINGID 'K'
  808. X#define MAXALIENS 3
  809. X
  810. X
  811. Xstruct sgttyb params;
  812. X
  813. Xchar *tgoto();
  814. Xchar *tgetstr();
  815. Xextern char *BC;
  816. Xextern char *UP;
  817. Xchar bp[1024];
  818. Xchar tbp[1024];
  819. Xchar *termp;
  820. X
  821. X/*variables for unbuffered input&output*/
  822. X#define BUFSIZE 512
  823. Xlong noofchars;
  824. X/*variables for unbuffered input&output*/
  825. X
  826. X/*variables for universe array*/
  827. Xstruct thing  {
  828. X        int x;
  829. X        char c;
  830. X        struct thing *next_thing;
  831. X          };
  832. X
  833. Xstruct thing *univ[918],*xp;
  834. X/*variables for universe array*/
  835. X
  836. X/*variables for the torpedos*/
  837. Xstruct torpedo {
  838. X        char weapon;
  839. X        int life;
  840. X        int xpos;
  841. X        int ypos;
  842. X        int oldxpos;
  843. X        int oldypos;
  844. X        int xvel;
  845. X        int yvel;
  846. X        struct player *whofrom;
  847. X        struct torpedo *next;
  848. X           };
  849. X
  850. Xstruct torpedo *tstartlist,*ttaillist,*txp,*ta;
  851. X/*variables for the torpedos*/
  852. X
  853. X/*variables for a player*/
  854. Xstruct player {
  855. X    int reason;
  856. X    char id; /*playing id*/
  857. X    char buf[BUFSIZE]; /*persons input buffer*/
  858. X    char message[57]; /*to radio others!*/
  859. X    int messindex;
  860. X    int buftop,bufptr; /*pointers to buffer for that person*/
  861. X    char terminalfile[14];
  862. X    char cm[20];
  863. X    char cl[20];
  864. X    int tty_type;
  865. X    int shipno;
  866. X    int fd; /*file descriptor to the tty file */
  867. X    /*horizontal size of window, IT MUST BE AN ODD NO!*/
  868. X    int pid; /*pid of process to be killed if this guy leaves the game*/
  869. X    /* plus all the other stuff a player needs!!! */
  870. X    int oldxpos;
  871. X    int oldypos;
  872. X    int xpos;
  873. X    int ypos;
  874. X    int xvel;
  875. X    int yvel;
  876. X    int maxvel;
  877. X    int energy;
  878. X    int maxenergy;
  879. X    int cloakingdevice;
  880. X    int beeping;
  881. X    int phaserbanks;
  882. X    int maxphaser;
  883. X    int photontorpedos;
  884. X    int maxphoton;
  885. X    int photonreach;
  886. X    int photonpower;
  887. X    int phaserreach;
  888. X    int phaserpower;
  889. X    int weaponselect; /*0=phaser, 1=photon*/
  890. X    int score;
  891. X    int shields;
  892. X    int oldstat;
  893. X    int stat;
  894. X    int chflg;
  895. X    int clflg;
  896. X    struct lock_on
  897. X        {
  898. X        struct player *enemy;
  899. X        int xloc;
  900. X        int yloc;
  901. X        } channel[4];
  902. X    int flyto;
  903. X    int planets[30];
  904. X    int planetno;
  905. X    int doneit;
  906. X    int impulsemove;
  907. X    struct player *next;
  908. X    };
  909. X
  910. X    struct player *player,*startlist,*taillist;
  911. X
  912. Xint players[10];
  913. X/*variables for a player*/
  914. Xint debug;
  915. Xint noofaliens,noofsignals,noofplayers;
  916. X
  917. X/*global general usage variables*/
  918. X
  919. Xint v,i,j,z,r,k,l,x,y,storm;
  920. Xchar c;
  921. X
  922. END_OF_FILE
  923. if test 3100 -ne `wc -c <'header.h'`; then
  924.     echo shar: \"'header.h'\" unpacked with wrong size!
  925. fi
  926. # end of 'header.h'
  927. fi
  928. if test -f 'keyscan.c' -a "${1}" != "-c" ; then 
  929.   echo shar: Will not clobber existing file \"'keyscan.c'\"
  930. else
  931. echo shar: Extracting \"'keyscan.c'\" \(1263 characters\)
  932. sed "s/^X//" >'keyscan.c' <<'END_OF_FILE'
  933. X
  934. X/*******************************************************************************
  935. X********************************************************************************
  936. X********************************************************************************
  937. X
  938. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  939. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  940. X
  941. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  942. X
  943. X
  944. X********************************************************************************
  945. X********************************************************************************
  946. X*******************************************************************************/
  947. X#include "header.h"
  948. X
  949. X/*******************USEFUL ROUTINES FOR LOW LEVEL I/O**************************/
  950. X
  951. Xgetbuf(cp,ptrnoofchars)
  952. Xregister struct player *cp;
  953. Xlong *ptrnoofchars;
  954. X{
  955. Xif (*ptrnoofchars>0)
  956. X{
  957. X/* get buffer from terminal */
  958. Xread(cp->fd,cp->buf,*ptrnoofchars);
  959. Xcp->buftop=(int)(*ptrnoofchars);
  960. Xcp->bufptr=0;
  961. X} 
  962. X}
  963. X
  964. Xflushbuf(cp)
  965. Xregister struct player *cp;
  966. X{
  967. Xcp->buf[0]='\0';
  968. Xcp->buftop=0;
  969. Xcp->bufptr=0;
  970. X}
  971. X
  972. Xgetchr(cp)
  973. Xregister struct player *cp;
  974. X{
  975. Xif (cp->bufptr==cp->buftop) /*is buffer empty?*/
  976. X    {    
  977. X    flushbuf(cp); 
  978. X    return('\0');
  979. X    } else
  980. X    return(cp->buf[cp->bufptr++]);
  981. X}
  982. X
  983. X
  984. END_OF_FILE
  985. if test 1263 -ne `wc -c <'keyscan.c'`; then
  986.     echo shar: \"'keyscan.c'\" unpacked with wrong size!
  987. fi
  988. # end of 'keyscan.c'
  989. fi
  990. if test -f 'makefile.dist' -a "${1}" != "-c" ; then 
  991.   echo shar: Will not clobber existing file \"'makefile.dist'\"
  992. else
  993. echo shar: Extracting \"'makefile.dist'\" \(1919 characters\)
  994. sed "s/^X//" >'makefile.dist' <<'END_OF_FILE'
  995. Xall:    mpss slave startrek mpssclean
  996. X
  997. Xstartrek:    ships.h planets.h header.h files.h aliens.o ships.o planets.o scan.o cross.o torpedo.o consoleplots.o cursor.o auto.o dock.o orbit.o keyscan.o main.o newplayer.o processinput.o collision.o setupuniverse.o
  998. X    cc -O aliens.o ships.o planets.o scan.o cross.o torpedo.o consoleplots.o cursor.o auto.o dock.o orbit.o keyscan.o main.o newplayer.o processinput.o collision.o setupuniverse.o -o startrek -ltermcap -lm
  999. X
  1000. Xslave:    ships.h files.h cursor.o ships.o slave.o
  1001. X    cc -O cursor.o ships.o slave.o -o slave -ltermcap  
  1002. X
  1003. Xmpss: files.h mpss.o
  1004. X    cc -O mpss.o -o mpss
  1005. X
  1006. Xmpss.o: files.h mpss.c
  1007. X    cc -O -c mpss.c
  1008. X
  1009. Xmpssclean : files.h mpssclean.o
  1010. X    cc -O mpssclean.o -o mpssclean
  1011. X
  1012. Xmpssclean.o:  files.h mpssclean.c
  1013. X          cc -O -c mpssclean.c
  1014. X
  1015. Xslave.o:  ships.h files.h slave.c
  1016. X          cc -O -c slave.c -ltermcap
  1017. X
  1018. Xcollision.o:  header.h collision.c
  1019. X          cc -O -c collision.c 
  1020. X
  1021. Xcross.o:  header.h cross.c
  1022. X          cc -O -c cross.c 
  1023. X
  1024. Xconsoleplots.o:  header.h consoleplots.c
  1025. X          cc -O -c consoleplots.c 
  1026. X
  1027. Xtorpedo.o:  header.h torpedo.c
  1028. X          cc -O -c torpedo.c 
  1029. X
  1030. Xcursor.o:  header.h cursor.c
  1031. X          cc -O -c cursor.c -ltermcap 
  1032. X
  1033. Xauto.o:  header.h auto.c
  1034. X          cc -O -c auto.c 
  1035. X
  1036. Xdock.o:  header.h dock.c
  1037. X          cc -O -c dock.c 
  1038. X
  1039. Xorbit.o:  planets.h header.h orbit.c
  1040. X          cc -O -c orbit.c 
  1041. X
  1042. Xkeyscan.o:  header.h keyscan.c
  1043. X          cc -O -c keyscan.c 
  1044. X
  1045. Xmain.o:  header.h files.h main.c
  1046. X          cc -O -c main.c 
  1047. X
  1048. Xnewplayer.o:  ships.h header.h files.h newplayer.c
  1049. X          cc -O -c newplayer.c 
  1050. X
  1051. Xaliens.o:  ships.h header.h aliens.c
  1052. X          cc -O -c aliens.c 
  1053. X
  1054. Xprocessinput.o: ships.h header.h processinput.c
  1055. X          cc -O -c processinput.c 
  1056. X
  1057. Xscan.o:  ships.h header.h scan.c
  1058. X          cc -O -c scan.c 
  1059. X
  1060. Xships.o:  ships.h ships.c
  1061. X          cc -O -c ships.c 
  1062. X
  1063. Xplanets.o:  planets.h planets.c
  1064. X          cc -O -c planets.c 
  1065. X
  1066. Xsetupuniverse.o:  planets.h header.h setupuniverse.c
  1067. X          cc -O -c setupuniverse.c 
  1068. X
  1069. END_OF_FILE
  1070. if test 1919 -ne `wc -c <'makefile.dist'`; then
  1071.     echo shar: \"'makefile.dist'\" unpacked with wrong size!
  1072. fi
  1073. # end of 'makefile.dist'
  1074. fi
  1075. if test -f 'mpssclean.c' -a "${1}" != "-c" ; then 
  1076.   echo shar: Will not clobber existing file \"'mpssclean.c'\"
  1077. else
  1078. echo shar: Extracting \"'mpssclean.c'\" \(548 characters\)
  1079. sed "s/^X//" >'mpssclean.c' <<'END_OF_FILE'
  1080. X#include <stdio.h>
  1081. X#include "files.h"
  1082. X#include <signal.h>
  1083. X
  1084. X
  1085. Xmain()
  1086. X{
  1087. Xint rpid;
  1088. Xchar string[15];
  1089. Xchar remove[80];
  1090. XFILE *f, *fopen();
  1091. X
  1092. Xsprintf(remove,"rm %s\n",PLAYERFILE);
  1093. Xsystem(remove);
  1094. Xsprintf(remove,"rm %s\n",LOCK);
  1095. Xsystem(remove);
  1096. Xsprintf(remove,"rm %s\n",PLAYERSCOREFILE);
  1097. Xsystem(remove);
  1098. Xsystem("stty -cbreak echo");
  1099. Xif ((f=fopen(MASTERPIDFILE,"r"))!=NULL) 
  1100. X    {
  1101. X    fgets(string,15,f); /*get pid*/
  1102. X    sscanf(string,"%d\n",&rpid);
  1103. X    kill(rpid,9);
  1104. X    fprintf(stdout,"killed\n");
  1105. X    fclose(f);
  1106. X    }
  1107. Xsprintf(remove,"rm %s\n",MASTERPIDFILE);
  1108. Xsystem(remove);
  1109. X}
  1110. END_OF_FILE
  1111. if test 548 -ne `wc -c <'mpssclean.c'`; then
  1112.     echo shar: \"'mpssclean.c'\" unpacked with wrong size!
  1113. fi
  1114. # end of 'mpssclean.c'
  1115. fi
  1116. if test -f 'mpssmail' -a "${1}" != "-c" ; then 
  1117.   echo shar: Will not clobber existing file \"'mpssmail'\"
  1118. else
  1119. echo shar: Extracting \"'mpssmail'\" \(0 characters\)
  1120. sed "s/^X//" >'mpssmail' <<'END_OF_FILE'
  1121. END_OF_FILE
  1122. if test 0 -ne `wc -c <'mpssmail'`; then
  1123.     echo shar: \"'mpssmail'\" unpacked with wrong size!
  1124. fi
  1125. chmod +x 'mpssmail'
  1126. # end of 'mpssmail'
  1127. fi
  1128. if test -f 'planets.h' -a "${1}" != "-c" ; then 
  1129.   echo shar: Will not clobber existing file \"'planets.h'\"
  1130. else
  1131. echo shar: Extracting \"'planets.h'\" \(790 characters\)
  1132. sed "s/^X//" >'planets.h' <<'END_OF_FILE'
  1133. X
  1134. X/*******************************************************************************
  1135. X********************************************************************************
  1136. X********************************************************************************
  1137. X
  1138. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  1139. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  1140. X
  1141. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  1142. X
  1143. X
  1144. X********************************************************************************
  1145. X********************************************************************************
  1146. X*******************************************************************************/
  1147. X
  1148. Xstruct plans {
  1149. X        int planno;
  1150. X        int xpos;
  1151. X        int ypos;
  1152. X        char *orbit;
  1153. X        char *land[19];
  1154. X           }  plan[];
  1155. X
  1156. END_OF_FILE
  1157. if test 790 -ne `wc -c <'planets.h'`; then
  1158.     echo shar: \"'planets.h'\" unpacked with wrong size!
  1159. fi
  1160. # end of 'planets.h'
  1161. fi
  1162. if test -f 'setupuniverse.c' -a "${1}" != "-c" ; then 
  1163.   echo shar: Will not clobber existing file \"'setupuniverse.c'\"
  1164. else
  1165. echo shar: Extracting \"'setupuniverse.c'\" \(2254 characters\)
  1166. sed "s/^X//" >'setupuniverse.c' <<'END_OF_FILE'
  1167. X
  1168. X/*******************************************************************************
  1169. X********************************************************************************
  1170. X********************************************************************************
  1171. X
  1172. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  1173. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  1174. X
  1175. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  1176. X
  1177. X
  1178. X********************************************************************************
  1179. X********************************************************************************
  1180. X*******************************************************************************/
  1181. X
  1182. X#include "header.h"
  1183. X#include "planets.h"
  1184. X
  1185. X/*rand number between 0 and X*/
  1186. Xrnd(s,x) 
  1187. Xint s,x;
  1188. X{
  1189. Xint i;
  1190. X
  1191. Xdo
  1192. X{
  1193. Xi=(int)(abs(rand()%100));
  1194. X}
  1195. Xwhile ((i<s)||(i>x));
  1196. Xreturn(i);
  1197. X}
  1198. X
  1199. Xadd(xx,y,cc) 
  1200. X int xx,y;
  1201. X char cc;
  1202. X{
  1203. X     char *malloc();
  1204. X    struct thing *a,*p,*r;
  1205. X
  1206. Xif (univ[y]==NULL)
  1207. X    {
  1208. X    univ[y]=(struct thing *)malloc(sizeof(struct thing));
  1209. X    univ[y]->x=xx;
  1210. X    univ[y]->c=cc;
  1211. X    univ[y]->next_thing=NULL;
  1212. X    } else
  1213. X    {
  1214. X    r=(struct thing *)malloc(sizeof(struct thing));
  1215. X    r->x=xx;
  1216. X    r->c=cc;
  1217. X
  1218. X    a=univ[y]; p=a->next_thing;
  1219. X    while ((p!=NULL)&&(p->x<=xx)) 
  1220. X        {
  1221. X        a=p;
  1222. X        p=p->next_thing;
  1223. X        }
  1224. X    if ((a==univ[y])&&(a->x>xx))
  1225. X        {
  1226. X        univ[y]=r;
  1227. X        r->next_thing=a;
  1228. X        } else
  1229. X        {
  1230. X        a->next_thing=r;
  1231. X        r->next_thing=p;
  1232. X        }
  1233. X    }
  1234. X}
  1235. X
  1236. Xsetupuniverse()
  1237. X{
  1238. X
  1239. Xnewgame();
  1240. X
  1241. Xfor (i=0; i<10; ++i)
  1242. X    players[i]=0;
  1243. X
  1244. Xfor (i=0; i<918; ++i) 
  1245. X    {
  1246. X    univ[i]=NULL;
  1247. X    }
  1248. X
  1249. Xadd(225,225,'*');
  1250. Xadd(225,675,'*');
  1251. Xadd(675,225,'*');
  1252. Xadd(675,675,'*');
  1253. X
  1254. Xadd(680,680,'k');
  1255. Xadd(670,670,'k');
  1256. Xadd(564,662,'k');
  1257. Xadd(470,488,'k');
  1258. X
  1259. Xadd(498,199,'#');
  1260. Xadd(501,197,'#');
  1261. Xadd(504,199,'#');
  1262. Xadd(498,203,'#');
  1263. Xadd(501,205,'#');
  1264. Xadd(504,203,'#');
  1265. X
  1266. Xadd(501,201,'o');
  1267. X
  1268. X
  1269. X/*planets*/
  1270. X
  1271. Xfor (r=0; r<30; ++r)
  1272. X    {
  1273. X    /*draw a planet....*/
  1274. X    add(plan[r].xpos,plan[r].ypos,'O');
  1275. X    }
  1276. X
  1277. X/*set up stars*/
  1278. Xfor (x=100; x<770; x+=60)
  1279. X    {
  1280. X    for (y=100; y<770; y+=25)
  1281. X    {
  1282. X        do
  1283. X        {
  1284. X            i=rnd(0,10);
  1285. X            j=rnd(0,15);
  1286. X        }
  1287. X        while (!(inuniv(x+i,y+j)==NULL));
  1288. X    k=rnd(0,100);
  1289. X    if (k<50) 
  1290. X        add(x+i,y+j,'.'); else
  1291. X        add(x+i,y+j,'@');
  1292. X    }
  1293. X    }
  1294. X}
  1295. X
  1296. Xinuniv(xx,y) 
  1297. Xint xx,y;
  1298. X{
  1299. Xregister struct thing *p;
  1300. X
  1301. Xp=univ[y];
  1302. X
  1303. Xwhile (p!=NULL)
  1304. X    {
  1305. X    if (p->x==xx) return(p->c);
  1306. X    p=p->next_thing;
  1307. X    }
  1308. X
  1309. Xreturn(NULL);
  1310. X}
  1311. X
  1312. END_OF_FILE
  1313. if test 2254 -ne `wc -c <'setupuniverse.c'`; then
  1314.     echo shar: \"'setupuniverse.c'\" unpacked with wrong size!
  1315. fi
  1316. # end of 'setupuniverse.c'
  1317. fi
  1318. if test -f 'ships.h' -a "${1}" != "-c" ; then 
  1319.   echo shar: Will not clobber existing file \"'ships.h'\"
  1320. else
  1321. echo shar: Extracting \"'ships.h'\" \(844 characters\)
  1322. sed "s/^X//" >'ships.h' <<'END_OF_FILE'
  1323. X
  1324. X/*******************************************************************************
  1325. X********************************************************************************
  1326. X********************************************************************************
  1327. X
  1328. XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  1329. XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  1330. X
  1331. X        P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  1332. X
  1333. X
  1334. X********************************************************************************
  1335. X********************************************************************************
  1336. X*******************************************************************************/
  1337. Xstruct ships {
  1338. X        char *name;
  1339. X        char *registration;
  1340. X        char *class; 
  1341. X        char *flag;
  1342. X        char *noofcrew;
  1343. X        char *prefixcode;
  1344. X        char *commissiondate;
  1345. X         }  ship[];
  1346. X
  1347. END_OF_FILE
  1348. if test 844 -ne `wc -c <'ships.h'`; then
  1349.     echo shar: \"'ships.h'\" unpacked with wrong size!
  1350. fi
  1351. # end of 'ships.h'
  1352. fi
  1353. echo shar: End of archive 4 \(of 4\).
  1354. cp /dev/null ark4isdone
  1355. MISSING=""
  1356. for I in 1 2 3 4 ; do
  1357.     if test ! -f ark${I}isdone ; then
  1358.     MISSING="${MISSING} ${I}"
  1359.     fi
  1360. done
  1361. if test "${MISSING}" = "" ; then
  1362.     echo You have unpacked all 4 archives.
  1363.     rm -f ark[1-9]isdone
  1364. else
  1365.     echo You still need to unpack the following archives:
  1366.     echo "        " ${MISSING}
  1367. fi
  1368. ##  End of shell archive.
  1369. exit 0
  1370.